﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace 并发秒杀系统
{
    class Program
    {
        static void Main(string[] args)
        {

            ThreadPool.SetMaxThreads(100, 100);
            ThreadPool.SetMinThreads(50, 50);

            ShopService shopService = new ShopService();

            // 模拟50个用户秒杀商品
            for (int i = 100; i < 150; i++)
            {
                int j = i;
                Task.Run(() =>
                {
                    shopService.DecrementShop(j.ToString());
                });
            }

            Console.ReadKey();

        }
    }
}
